import redis
class RedisConn:

    def __init__(self) -> None:
        self.r = redis.Redis()

    # 字符串添加
    def str_add(self,key,value,time=0):
        if time == 0:
            self.r.set(key,value)
        else:
            self.r.setex(key,time,value)

    # 字符串获取
    def str_get(self,key):
        value = self.r.get(key)
        if value:
            value = value.decode()
        return value
    # 删除
    def del_str(self,key):
        return self.r.delete(key)

r = RedisConn()
# r.str_add("name","abc")
# print(r.str_get("name1"))